import { Controller, Get, Query } from '@nestjs/common';
import { ClientService } from './client.service';
import { ResultData } from 'src/common/utils/result';
import { ListClientDto } from './dto';
import { User, UserDto } from '../user/user.decorator';
import { RequireRole } from 'src/common/decorator/require-role.decorator';
import { RoleEnum } from 'src/common/enum';

@Controller('client')
export class ClientController {
  constructor(private readonly clientService: ClientService) {}

  @Get('list')
  @RequireRole([RoleEnum.enterprise_boss, RoleEnum.enterprise_admin])
  async findAll(@Query() listClientDto: ListClientDto, @User() user: UserDto) {
    const result = await this.clientService.findAll(listClientDto, user);
    return ResultData.ok(result);
  }
}
